using AiQiuQuan.Sport.Model.Models;
using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;

namespace AiQiuQuan.Sport.WebApi.Controllers
{
    /// <summary>
    /// 平台场馆管理
    /// </summary>
    public class PlatformVenueController : PcApiController
    {
        private readonly IVenueService _venueService;

        /// <summary>
        /// cotr
        /// </summary>
        public PlatformVenueController(
            IVenueService venueService)
        {
            _venueService = venueService;
        }

        /// <summary>
        /// 审核提现
        /// </summary>
        [HttpPost("audit_withdraw")]
        [AllowAnonymous]
        public async Task<UnaryResult> AuditWithdrawAsync(VenueAuditWithdrawRequestDto request)
        {
            var result = await _venueService.AuditWithdrawAsync(request);
            return result;
        }

        /// <summary>
        /// 查询
        /// </summary>
        [HttpGet("get")]
        public async Task<UnaryResult<VenueInfoDto>> GetAsync([Required] Guid id)
        {
            var result = await _venueService.GetAsync(id);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 分页查询
        /// </summary>
        [HttpPost("pagelist")]
        [AllowAnonymous]
        public async Task<UnaryResult<PageResult<VenueInfoDto>>> PageListAsync(VenuePageRequestDto request)
        {
            request.IsPlatform = true;
            var result = await _venueService.PageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 教练场馆分页
        /// </summary>
        [HttpPost("pagelist_coacher_venue")]
        public async Task<UnaryResult<PageResult<VenueInfoDto>>> PageListCoacherAsync(VenuePageRequestDto request)
        {
            var result = await _venueService.PageListCoacherAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 场地分页列表
        /// </summary>
        [HttpPost("pagelist_site")]
        public async Task<UnaryResult<PageResult<SiteInfoDto>>> GetVenueSitePageListAsync(VenueSitePageRequestDto request)
        {
            var result = await _venueService.GetVenueSitePageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 场地特殊规则分页列表
        /// </summary>
        [HttpPost("pagelist_site_rule")]
        public async Task<UnaryResult<PageResult<SitePriceSpecialRuleDto>>> GetVenueSiteSpecialRulePageListAsync(VenueSitePageRequestDto request)
        {
            var result = await _venueService.GetVenueSiteSpecialRulePageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 场馆退款规则分页列表
        /// </summary>
        [HttpPost("pagelist_refundrule")]
        public async Task<UnaryResult<PageResult<VenueInfoRefundRuleSimpleDto>>> GetVenueRefundRulePageListAsync(VenuePageRequestDto request)
        {
            var result = await _venueService.GetVenueRefundRulePageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 场馆退款规则列表
        /// </summary>
        /// <param name="venueId">场馆ID</param>
        [HttpGet("list_refundrule")]
        public async Task<UnaryResult<List<VenueInfoRefundRuleConfigDto>>> GetVenueRefundRuleListAsync([Required] Guid venueId)
        {
            var result = await _venueService.GetVenueRefundRuleListAsync(venueId);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 场馆场地价格列表
        /// </summary>
        [HttpPost("get_site_price_info")]
        public async Task<UnaryResult<SitePriceSimpleDto>> GetSitePriceSimpleInfoAsync(SitePriceSimpleRequestDto request)
        {
            var result = await _venueService.GetSitePriceSimpleInfoAsync(request);
            return UnaryResult.Succeed(result);
        }
    }
}
